package com.crm.service.impl.contractManager;

import com.crm.common.model.Enum.StatusCodeEnum;
import com.crm.dao.mapper.contractManager.CustomerContractDeveloperMapper;
import com.crm.dao.mapper.customMapper.customerContractCustomMapper.CustomerContractCustomMapper;
import com.crm.model.entity.contractManager.CustomerContractDeveloper;
import com.crm.model.entity.contractManager.CustomerContractDeveloperExample;
import com.crm.service.contractManager.CustomerContractDbService;
import com.crm.service.contractManager.CustomerContractDeveloperDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author luojie
 * @date 2021/3/17 15:41
 */
@Service
public class CustomerContractDeveloperDbServiceImpl implements CustomerContractDeveloperDbService {

    @Autowired
    private CustomerContractDeveloperMapper customerContractDeveloperMapper;

    @Autowired
    private CustomerContractCustomMapper customerContractCustomMapper;

    /**
     * 新增合作开发人员数据
     * @param customerContractDeveloper
     * @author luojie
     * @return
     */
    @Override
    public Boolean insertCustomerContractDeveloper(CustomerContractDeveloper customerContractDeveloper){
        int num = customerContractDeveloperMapper.insert(customerContractDeveloper);
        return num > 0;
    }

    /**
     * 合同列表--合同详情(根据合同ID查询合作开发人员集合)
     * @param contractId ---合同ID
     * @author yincuimei
     * @return
     */
    @Override
    public List<CustomerContractDeveloper> selectCustomerContractDeveloperList(String contractId) {
        CustomerContractDeveloperExample contractDeveloperExample = new CustomerContractDeveloperExample();
        CustomerContractDeveloperExample.Criteria criteria = contractDeveloperExample.createCriteria();
        criteria.andContractIdEqualTo(contractId);
        criteria.andDeleteStatusEqualTo((short) StatusCodeEnum.NORMAL_CODE.getState());
        return customerContractDeveloperMapper.selectByExample(contractDeveloperExample);
    }

    @Override
    public List<String> selectCustomerContractDeveloperHistoryContractIdList() {
        return customerContractCustomMapper.selectCustomerContractDeveloperHistoryContractIdList();
    }
}
